package com.abel.day0307;

import java.util.ArrayList;
import java.util.concurrent.locks.Lock;

/**
 * @author xiachao
 * @date 2019/3/7
 */
public class Solution {

    public ArrayList<ArrayList<Integer>> FindContinuousSequence(int sum) {
        ArrayList<ArrayList<Integer>> ret = new ArrayList<ArrayList<Integer>>();
        for(int i=1;i<=sum/2;i++){
            int t = i;
            ArrayList<Integer> arr = new ArrayList<Integer>();
            arr.add(i);
            for(int j=i+1;j<=sum/2+1;j++){
                t += j;
                arr.add(j);
                if(t == sum){
                    ret.add(arr);
                    break;
                }
                if(t > sum){
                    break;
                }
            }
        }
        return ret;
    }

//    public ArrayList<Integer> FindNumbersWithSum(int [] array,int sum) {
//
//
//    }

    public String LeftRotateString(String str,int n) {
        if(str.length() < n){
            return null;
        }
        String ret = "";
        for(int i=n;i<str.length();i++){
            ret += str.charAt(i);
        }
        for(int i=0;i<n;i++){
            ret += str.charAt(i);
        }
        return ret;
    }

    public void FindNumsAppearOnce(int [] array, int num1[], int num2[]) {

    }

    public String ReverseSentence(String str) {
        if(str == ""){
            return " ";
        }
        String [] arr = str.split("\\s++");
        String ret = "";
        for(int i=arr.length-1;i>=0;i--){
            ret+=arr[i];
            ret+=" ";
        }
        return ret.trim();
    }

    public static void main(String[] args) {
        //System.out.println(new Solution().FindContinuousSequence(3));
        //System.out.println(new Solution().LeftRotateString("abcXYZdef", 3));
        //System.out.println(new Solution().ReverseSentence("student. a am I"));
        System.out.println(1^2^2);
        System.out.println(2^3^4^4^5^5);

    }
}
